import ctypes

user32 = ctypes.windll.user32
CopyImage = user32.CopyImage
LoadImageW = user32.LoadImageW
SetSystemCursor = user32.SetSystemCursor

IMAGE_CURSOR = 2
LR_SHARED = 32768
LR_COPYFROMRESOURCE = 16384
LR_LOADFROMFILE = 16
OCR_NORMAL = 32512


import time

# 准备工作
FILE_NAME_CURSOR = ".\\assets\\target_3.ani"
hold = LoadImageW(0, OCR_NORMAL, IMAGE_CURSOR, 0, 0, LR_SHARED)
hsave = CopyImage(hold, IMAGE_CURSOR, 0, 0, LR_COPYFROMRESOURCE)
hnew = LoadImageW(0, FILE_NAME_CURSOR, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE)
print("替换光标倒计时……1");time.sleep(1)
# 替换光标
SetSystemCursor(hnew, OCR_NORMAL);print("已替换光标")
print("还原光标倒计时……3");time.sleep(1)
print("还原光标倒计时……2");time.sleep(1)
print("还原光标倒计时……1");time.sleep(1)
# 还原光标
SetSystemCursor(hsave, OCR_NORMAL);print("已还原光标")
# hold = LoadImageW(0, OCR_NORMAL, IMAGE_CURSOR, 0, 0, LR_SHARED)
hsave = CopyImage(hold, IMAGE_CURSOR, 0, 0, LR_COPYFROMRESOURCE)
hnew = LoadImageW(0, FILE_NAME_CURSOR, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE)
print("替换光标倒计时……3");time.sleep(1)
print("替换光标倒计时……2");time.sleep(1)
print("替换光标倒计时……1");time.sleep(1)
# 替换光标
SetSystemCursor(hnew, OCR_NORMAL);print("已替换光标")
print("还原光标倒计时……3");time.sleep(1)
print("还原光标倒计时……2");time.sleep(1)
print("还原光标倒计时……1");time.sleep(1)
# 还原光标
SetSystemCursor(hsave, OCR_NORMAL);print("已还原光标")
# hold = LoadImageW(0, OCR_NORMAL, IMAGE_CURSOR, 0, 0, LR_SHARED)
hsave = CopyImage(hold, IMAGE_CURSOR, 0, 0, LR_COPYFROMRESOURCE)
hnew = LoadImageW(0, FILE_NAME_CURSOR, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE)
print("已结束……")
